impl Solution {
    pub fn min_operations(mut n: i32) -> i32 {
        let mut ans=0;
        if n==0{
            return  0;
        }
        while n!=1 {
            if n&3==3{
                n=n+1;
                ans+=1;
                continue;
            }
            if n&1!=0{
                n-=1;
                ans+=1;
            }
            n>>=1;

        }
        ans+1

    }
}
